<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>修改代码，右边会自动显示结果</title>
<!--适应移动端-->
<meta name="viewport" content="width=device-width, initial-scale=1">
<!--css样式-->
<style>
	.container, .result {
		// background-color: #ebebeb;
		margin-left: auto;
		margin-right: auto;
		width: 700px;
	}
	.result {
		padding-top: 20px;
		padding-left: 50px;
	}
	.aaa, .bbb, .ccc {
		display: inline-block;
		text-align: center;
		color: #fff;
		background-color: #30af70;
		padding: 10px;
		cursor: pointer;
		margin-left: 25px;
		margin-right: 25px;
		width: 150px;
	}
	.aaa:hover, .bbb:hover, .ccc:hover{
		background-color: #03cf8b;
	}
</style>
<!--引用jquery库-->
<script src="https://s1.pstatp.com/cdn/expire-1-M/jquery/1.10.2/jquery.min.js"></script>
</head>

<body>
<div class="container">
	<div class="aaa">获取 token</div>
	<div class="bbb">回传分数</div>
	<div class="ccc">上传报告</div>
</div>
<div class="result">
</div>
<script type="text/javascript">
	$(document).ready(function(){
	      //点击
		  $(".aaa").click(function(){
			$.ajax({
				type: 'GET',
				url: 'http://192.168.2.78:8180/oauth/token/accesstoken?appid=1681600222748241929&signature=6CC426EF80A31C5E7BDE10F6F5772DE5&ticket=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJST05DT08iLCJleHAiOjE3MTM2OTIwNjUsInVzZXJJZCI6IjE3MDE4MDgxNjk3OTMxMzg2OTAifQ.FfUkZ_Z-Acwird66oHfg2PnWqhlY9g39i1Y9cOidgBI',
				// contentType: "application/json",
				// dataType: "jsonp",
				success: function(res){					
					console.log(res);
					$('.result').text(JSON.stringify(res));
				},
				error: function(res){
				    console.log(res);
				    $('.result').text(JSON.stringify(res));
				}
			});
		  });
		  $(".bbb").click(function(){
			$.ajax({
				type: 'POST',
				url: "http://192.168.2.78:8180/oauth/api/v1/data_upload?access_token=" + access_token,
				// data: score,
				data: JSON.stringify(score),
				// datatype: 'json',
				contentType: "application/json",  
				crossDomain: true,
				success: function(res){
					console.log(res);
					$('.result').text(JSON.stringify(res));
				},
				error: function(res){
					console.log(res);
					$('.result').text(JSON.stringify(res));
				}
			});			
		  });
		  
		  $(".ccc").click(function(){
			$.ajax({
				type: 'POST',
				url: "http://192.168.2.78:8180/oauth/api/v1/attachment_upload?appid=" + appid + "&originId=" + originId + "&filename=" + filename + "&title=" + title + "&access_token=" + access_token,
				// data: score,
				data: contents,
				// datatype: 'json',
				contentType: "application/json",  
				crossDomain: true,
				success: function(res){
					console.log(res);
					$('.result').text(JSON.stringify(res));
				},
				error: function(res){
					console.log(res);
					$('.result').text(JSON.stringify(res));
				}
			});			
		  });		  
		  
		  const appid = '1681600222748241929';
		  const originId = 66661111112;
		  const filename = 'report.txt';
		  const title = '报告';
		  const access_token = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJtc2ciOiLosIPnlKjmiJDlip_vvIzov5Tlm57miYDpnIDmlbDmja4iLCJjb2RlIjowLCJjcmVhdGVfdGltZSI6MTcxMTUyMTU5MDE4OSwiY3JlYXRlX3RpbWVfZGlzcGxheSI6IjIwMjQtMDMtMjcgMTQ6Mzk6NTAiLCJ1c2VyX25hbWUiOiIxNzAxODA4MTY5NzkzMTM4NjkwIiwiYXV0aG9yaXRpZXMiOlsiQURNSU4iXSwiY2xpZW50X2lkIjoiMTY4MTYwMDIyMjc0ODI0MTkyOSIsImRpcyI6IjE3MDE4MDgxNjk3OTMxMzg2OTAiLCJzY29wZSI6WyJjYWxsYmFjazpzY29yZSJdLCJleHBpcmVzX3RpbWVfZGlzcGxheSI6IjIwMjQtMDMtMjggMTQ6Mzk6NDkiLCJ1biI6IjE3MDE4MDgxNjk3OTMxMzg2OTAiLCJleHAiOjE3MTE2MDc5OTAsImp0aSI6ImZlNWQ5MTNlLTgxYzMtNGIzOC1hNjVhLTQwMTQ2ZDgzMTE5ZCIsImV4cGlyZXNfdGltZSI6MTcxMTYwNzk4OTE4OX0.MpiNFyEuoROTGgYMBfODZdQtNl556-kY7A7DIETGeKQ';
		  const score = {
			  "username": "1701808169793138690",
			  "title": "实验名称",
			  "childProjectTitle": "子实验/模块名称",
			  "status": 1,
			  "score": 100,
			  "startTime": 1522646936023,
			  "endTime": 1522647936001,
			  "timeUsed": 900,
			  "appid": "1681600222748241929",
			  "originId": originId,
			  "group_id": "1",
			  "group_name": "分组名称",
			  "role_in_group": "学生,教师",
			  "group_members": "张三,李四",
			  "steps": [
				  {
					  "seq": 1,
					  "title": "实验步骤1",
					  "startTime": 1522646936000,
					  "endTime": 1522647936000,
					  "timeUsed": 900,
					  "expectTime": 2,
					  "maxScore": 10,
					  "score": 10,
					  "repeatCount": 1,
					  "evaluation": "优",
					  "scoringModel": "赋分模型",
					  "remarks": "备注"
				  }
			  ]
		  };
		  
		  const contents = JSON.stringify(score);
	});
</script>

</body>
</html>